ngl: Avoid huge intermediate textures
authorMatthias Clasen <mclasen@redhat.com>
Fri, 2 Apr 2021 23:33:44 +0000 (19:33 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 2 Apr 2021 23:33:44 +0000 (19:33 -0400)
Instead of rendering the unclipped child to a texture
(and risking blowing the texture size limit, and bad
downscaling), just render the clipped region, and live
with the fact that we can't cache the rendered texture.

This avoid bad artifacts when scrolling long textviews
in rounded clips.

gsk/ngl/gsknglrenderjob.c

index 890983f07d913d700d206f5b907dae7ceb0aff99..0bd6c94b68987d8d9f9959836072ee7e01714c90 100644 (file)
@@ -1498,21 +1498,14 @@ gsk_ngl_render_job_visit_clipped_child (GskNglRenderJob       *job,
     }
   else
     {
-      GskRoundedRect scaled_clip;
       GskNglRenderOffscreen offscreen = {0};
 
-      offscreen.bounds = &child->bounds;
+      offscreen.bounds = clip;
       offscreen.force_offscreen = TRUE;
-      offscreen.reset_clip = FALSE;
-
-      scaled_clip = GSK_ROUNDED_RECT_INIT ((job->offset_x + clip->origin.x) * job->scale_x,
-                                           (job->offset_y + clip->origin.y) * job->scale_y,
-                                           clip->size.width * job->scale_x,
-                                           clip->size.height * job->scale_y);
+      offscreen.reset_clip = TRUE;
+      offscreen.do_not_cache = TRUE;
 
-      gsk_ngl_render_job_push_clip (job, &scaled_clip);
       gsk_ngl_render_job_visit_node_with_offscreen (job, child, &offscreen);
-      gsk_ngl_render_job_pop_clip (job);
 
       g_assert (offscreen.texture_id);
 
@@ -1522,7 +1515,7 @@ gsk_ngl_render_job_visit_clipped_child (GskNglRenderJob       *job,
                                            GL_TEXTURE_2D,
                                            GL_TEXTURE0,
                                            offscreen.texture_id);
-      gsk_ngl_render_job_draw_offscreen_rect (job, &child->bounds);
+      gsk_ngl_render_job_draw_offscreen_rect (job, clip);
       gsk_ngl_render_job_end_draw (job);
     }
 }